//index.js
//获取应用实例
const app = getApp()
import {ClassicModel} from '../../models/classic.js'
import {indexData} from '../../mock/index.js'
let classic = new ClassicModel()

Page({
  data: {
    motto: 'Hello World',
    classicData: {},
    userInfo: {},
    hasUserInfo: false,
    canIUse: wx.canIUse('button.open-type.getUserInfo')
  },
  //事件处理函数
  bindViewTap: function() {
    wx.navigateTo({
      url: '../my/my'
    })
  },
  bindMapTap: function() {
    wx.navigateTo({
      url: '../list/list'
    })
  },
  onLoad: function () {
    // 页面渲染后 执行
    // classic.getLatest((res)=> {
      console.log(indexData)
      this.setData({
        classicData: indexData
      })
    // })
  },
  onLike: function(e){
    let behavier = e.detail.behavier
  },
  getUserInfo: function(e) {
    app.globalData.userInfo = e.detail.userInfo
    this.setData({
      userInfo: e.detail.userInfo,
      hasUserInfo: true
    })
  }
})
